<?php
    session_start();
    
    include("language.php");
    include('database.php');
    
    $_SESSION['curPage'] = 'listMember.php';
    
    if(isset($_SESSION['connected']) AND $_SESSION['connected'])
    {
        if($_SESSION['access'] != 10)
        {
          header("Location: error.php");
        }
        else
        {
            if(isset($_POST['id']))
            {
                $db->query("DELETE from user WHERE id=\"".$_POST['id']."\""); 
            }
        }
    }
    else header("Location: error.php");
?>
<!DOCTYPE html>
<html>
    <head>
            <meta charset="utf-8" />
            <link rel="stylesheet" href="style.css" />
    </head>
    <body>
        <div class="d_body">
            <?php include('header.php'); ?>
             <br>
        <div class="d_menuBar">
        <ul class="menuBarTable">
           <li><a href="home.php">Acceuil</a></li>
           <li><a href="listMember.php">Liste des membres</a></li>
           <li><a href="addTickets.php">Ajout tickets</a></li>       
           <li><a href="idTicketByDraw.php">Liste Ticket</a></li>
         </ul>
            </div>
             
     <?php

       
	$query=$db->query("SELECT id, username FROM user");

        
        echo '<br><br><br><br><br><form method=post action="listMember.php">
        <center><table class="listMember">
        
        <th class="td_listerMember">Numéro</th><th class="td_listerMember">Pseudo</th><th class="td_listerMember">Supprimer</th>';
       
         while($data = $query->fetch()) 
         { 
             echo '<tr><td class="td_listerMember">'.$data['id'].'</td>';
             echo '<td class="td_listerMember">'.$data['username'].'</td>';
             echo '<td class="td_listerMember"><input type = submit name="id" value='.$data['id'].'></input></td></tr>';
          }   
             echo '</table><center></form>';        

         ?>   
       
      </div>
    </body>
</html>
        